<?php

/**
 * Tournament form base class.
 *
 * @method Tournament getObject() Returns the current form's model object
 *
 * @package    makethetouch
 * @subpackage form
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseTournamentForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'                   => new sfWidgetFormInputHidden(),
      'description'            => new sfWidgetFormTextarea(),
      'expected_referee_level' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('RefereeLevel'), 'add_empty' => false)),
      'organisator'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Person'), 'add_empty' => false)),
      'referee_director'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Person_2'), 'add_empty' => true)),
      'venue'                  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Address'), 'add_empty' => false)),
      'begin_date'             => new sfWidgetFormDate(),
      'end_date'               => new sfWidgetFormDate(),
      'final_function_address' => new sfWidgetFormInputText(),
      'team_fee'               => new sfWidgetFormInputText(),
      'player_fee'             => new sfWidgetFormInputText(),
      'national_team'          => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'name'                   => new sfValidatorChoice(array('choices' => array($this->getObject()->get('name')), 'empty_value' => $this->getObject()->get('name'), 'required' => false)),
      'description'            => new sfValidatorString(array('max_length' => 500, 'required' => false)),
      'expected_referee_level' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('RefereeLevel'))),
      'organisator'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Person'))),
      'referee_director'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Person_2'), 'required' => false)),
      'venue'                  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Address'))),
      'begin_date'             => new sfValidatorDate(array('required' => false)),
      'end_date'               => new sfValidatorDate(array('required' => false)),
      'final_function_address' => new sfValidatorInteger(array('required' => false)),
      'team_fee'               => new sfValidatorNumber(array('required' => false)),
      'player_fee'             => new sfValidatorNumber(array('required' => false)),
      'national_team'          => new sfValidatorInteger(),
    ));

    $this->widgetSchema->setNameFormat('tournament[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Tournament';
  }

}
